import auchCRCLo from './auchCRCLo.js'
import auchCRCHi from './auchCRCHi.js'

function CRC16_1(data, len = 0) {
	const array8 = new Uint8Array(len)
	array8.set(data.subarray(0, len), 0)
	
	let crc
	if(len){
		crc = 0x0000
		for(let i = 0; i < len; i++) {
			crc = (crc ^ (array8[i]))
			for(let j = 0; j < 8; j++) {
				crc = (crc & 1) != 0 ? ((crc >> 1) ^ 0xA001) : (crc >> 1)
			}
		}
	} else {
		crc = [0, 0]
	}
	
	return crc
}

export {
	CRC16_1
}